home *** CD-ROM | disk | FTP | other *** search
/ Dynamic HTML Construction Kit / Dynamic HTML Construction Kit.iso / earthlink / nscomm / java40.jar / sun / awt / windows / WFontMetrics.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-11-03  |  1.4 KB  |  77 lines

  1. package sun.awt.windows;
  2.  
  3. import java.awt.Font;
  4. import java.awt.FontMetrics;
  5. import java.util.Hashtable;
  6.  
  7. class WFontMetrics extends FontMetrics {
  8.    int[] widths;
  9.    int ascent;
  10.    int descent;
  11.    int leading;
  12.    int height;
  13.    int maxAscent;
  14.    int maxDescent;
  15.    int maxHeight;
  16.    int maxAdvance;
  17.    static Hashtable table = new Hashtable();
  18.  
  19.    public WFontMetrics(Font var1) {
  20.       super(var1);
  21.       this.loadFontMetrics();
  22.    }
  23.  
  24.    public int getLeading() {
  25.       return this.leading;
  26.    }
  27.  
  28.    public int getAscent() {
  29.       return this.ascent;
  30.    }
  31.  
  32.    public int getDescent() {
  33.       return this.descent;
  34.    }
  35.  
  36.    public int getHeight() {
  37.       return this.height;
  38.    }
  39.  
  40.    public int getMaxAscent() {
  41.       return this.maxAscent;
  42.    }
  43.  
  44.    public int getMaxDescent() {
  45.       return this.maxDescent;
  46.    }
  47.  
  48.    public int getMaxAdvance() {
  49.       return this.maxAdvance;
  50.    }
  51.  
  52.    public native int stringWidth(String var1);
  53.  
  54.    public native int charsWidth(char[] var1, int var2, int var3);
  55.  
  56.    public native int bytesWidth(byte[] var1, int var2, int var3);
  57.  
  58.    public int[] getWidths() {
  59.       if (this.widths == null) {
  60.          this.loadFontMetrics();
  61.       }
  62.  
  63.       return this.widths;
  64.    }
  65.  
  66.    native void loadFontMetrics();
  67.  
  68.    static synchronized FontMetrics getFontMetrics(Font var0) {
  69.       Object var1 = (FontMetrics)table.get(var0);
  70.       if (var1 == null) {
  71.          table.put(var0, var1 = new WFontMetrics(var0));
  72.       }
  73.  
  74.       return (FontMetrics)var1;
  75.    }
  76. }
  77.